<template>
  <basic-container>
    <avue-form :option="option" v-model="form" @submit="handleSubmit"/>
  </basic-container>
</template>

<script>
  import {expenseProcess} from "@/api/work/expense";

  export default {
    data() {
      return {
        form: {},
        option: {
          group: [
            {
              icon: 'el-icon-info',
              label: '提交图纸基础信息',
              prop: 'group1',
              column: [
                {
                  label: '审批内容',
                  prop: 'content',
                  row:true,
                  rules: [
                    {
                      required: true,
                      message: '请输入审批内容',
                      trigger: 'blur'
                    }
                  ]
                },
                {
                  label: '备注',
                  prop: 'comment',
                  rules: [
                    {
                      required: true,
                      message: '请输入请假理由',
                      trigger: 'blur'
                    }
                  ]
                },
              ]
            },
          ],
        }
      }
    },
    methods: {
      handleSubmit() {
        const params = {
          processDefinitionId: this.$route.params.processDefinitionId,
          ...this.form,
        };
        expenseProcess(params).then(resp => {
          const data = resp.data;
          if (data.success) {
            this.$message.success(data.msg);
            this.$router.$avueRouter.closeTag();
            // this.$router.push({path: `/work/start`});
            this.$router.go(-1);
          } else {
            this.$message.error(data.msg || '提交失败');
          }
        });
      }
    }
  }
</script>
